Variable frequency drive (VFD) is a whole science and even a very broad deliberation here will not give you any good picture. I was teaching VFD course for one of the manufacturers and for an introductory session I talked for 8 hours, full course - 5 days and this is still just facts. Surely, you can buy 1HP VFD hook to 1HP motor and it is going to work regulating the speed by a pot on it. However, if you buy 4MW (that is 4 mega watts) VFD to run pilot testing centrifugal spinner on 3.6MW motor - that's completely different animal that carry enormous, neck breaking tech problems.
The simplest definition (my students liked): "VFD is a device that make stupid motor smart..."
Stupid Motor: (called induction motor, asynchro, squirrel cage...) - give it a voltage it wants at local frequency then the current will jump to about 6 times what was promised on its name plate for couple seconds and it will run delivering the promised torque. The speed (rpm) will be fixed, slightly dependent on the torque demand. Good solution for kitchen fan, scrap conveyor via gear etc. Take the voltage off and it will coast to stop. That's about all such setup can do.
Smart Motor: (which is run by the VFD) - now we are talking... You can regulate the speed but this is just the beginning. You have control of: min/max speed, via digital inputs you can have e.g. 8 predefined speed embedded inside, define bust, constant or variable torque (that delivers the torque when needed = money saving), control PID loop for HVAC, you can avoid resonance frequencies, you can set different acceleration and deceleration time an you can set S-curve. Now you can talk to the motor via RS485 or other means deciding how it shall run at certain moment of a process, you can stop the motor in short time injecting DC etc. There are also other, way more sophisticated capabilities - e.g. some VFDs will allow you to reverse the slippage characteristic (a treasure in crude pumping) and have internal PLC that allow you to run a whole machine on it. They may have internal clock that can run automatically e.g. air cooling fan in a plant but only when the workers are in, let say 9am-5pm. Further on, the modern VFD's run whatever you hook up to them – induction motor, IM+encoder, encoder less vector, SPM motors etc. You can run the motor in speed, torque or position mode (w/ pg) and having 2 motors and 2 drives you can relate speed of one to the other, also you may scale it at will.
There is (for the better one) about 500 parameters that allow you do things that you want but also 90% things that are hard to imagine. Note - the contemporary VFD's slowly but surely approaches the intelligence of servo motors thus the stupid motors with the modern brain addition become very, very smart (note: servo still have way better torque to inertia ratio = response time).