215/45 has sidewall height of around 9.7cm (21.5cm X 45% = 9.7cm) while 215/40 only has sidewall height of 8.6cm (21.5cm x 40% = 8.6cm). So the radius is smaller by 1.1cm, meaning overall/outer diameter is smaller by 2.2cm!
Now compared to your stock size 195/65/15, the overall diameter is actually even bigger at 63.5cm while 215/45/17 is only 62.5cm. Imagine if using 215/40/17 which is only 60.4cm, it will look so small! Diameter wise, actually then the best match are either 205/50/17 or 225/45/17. If use 205/50/17 then easier to clear but if 225/45/17 then you need to make sure you get rims with more precise offset so it would not rub. Ideally you should then use 205/50/17 but this size is much more rare, while 225/45/17 is much more common.
You can play around with this tire conversion calculator to understand better what I've said above:
https://www.wheel-size.com/calc/?wh...-17X7.5ET39&fcl=30mm&scl=50mm&wcl=30mm&sr=0mm