I watched a video and downloaded with idm in 720p. I don't like the resolution and I decided to download 1080p. But I saw 720p is nearly 21 MB but 1080p is 10 MB. And I opened the video(1080p) I saw it is better than 720p. Why?
I tried this with the video provided in the comment. The reason why the 1080p video is smaller is because it has a lower bit-rate (327 vs. ~207 Kbps). In the case of this type of content its likely that the bit-rate for the 720p version is too high. Same for the audio the 1080p version has 96 Kbps and the 720p version has 144-155 Kbps.
A possible reason why this is the case, is how YouTube handles 720p and 1080p video. Unlike the 720p stream the 1080p stream isn't truly constant in it's bit-rate. For 1080p YouTube uses a protocol called "DASH" which adapts the bitrate of the video on the fly to meet the bandwidth constrains of the user which might change during streaming. You get lots of video bits from the server which might differ in bit-rate depending on your current connection. So if you download the same video on a very slow connection it will probably be even smaller.
In this case it saved you bandwidth while having better quality, in other cases the 1080p video could actually look worse than the 720p video, though DASH is pretty smart so usually you will probably end up with a better looking 1080p.