Yes, it is ethical, but it can't be done in a vacuum. You don't just throw an unqualified person at a group of students and expect anything good to come from it. But, where this is done, there are normally some controls in place.
For example, a graduate student given sole responsibility for a course will probably have TA'd in the course previously, working with a regular faculty member. It is also likely that there will be a regular faculty member responsible for some oversight. Most such courses are elementary, where the graduate student can be assumed to be thoroughly familiar with the material, at least, if not with pedagogy.
Also, there is normally a selection process in which some thought is given to who should teach these courses. Again, normally, the students will be somewhat experienced and will have seen a lot of professors and will likely get some sense, imperfect of course, on how to go about it.
But, I think it would be extremely rare for a grad student to be completely responsible for the course design and delivery. Likely the syllabus and learning materials are chosen by others. The exams may be graded collectively if there are a large number of such "sections" of a course. Student complaints would be taken seriously.
And some grad students do get a bit of practice in lecturing, at least when a prof assigns them the task of preparing and delivering a lecture on some topic in a course they are taking. I had this (unsettling) experience as an undergraduate, actually.
In the US, it is rare, in fact, for a new Assistant Professor of mathematics to have any formal training at all in pedagogy. I think this is different in EU, as colleagues there have expressed a bit of horror when they learn of this. New faculty struggle along and hopefully don't do too much damage.