These small devices you plug into your TV are known as media streamers. They contain a small computer with some memory and you connect them to your TV and the Internet using Wifi or an ethernet cable to your router.
They are intended to run programs that give you access to video streaming services over the Internet. They present a nice menu on your TV for allowing you to select which service you want to use with a remote control.
Amazon, Roku, Apple and many other companies sell these and they commonly bundle many media streaming services such as BBC IPlayer, Nexflix, etc and many others that may not require a subscription.
Now the hardware in these little gadgets is commonly available and many other companies can produce these media streamers to plug into your TV. Moreover, they also run regular computer operating systems like Android or Linux.
Kodi is a media playing program designed to run on one of these media streamers and it can do much the same thing as Amazon, Roku, etc, but it goes way beyond their carefully curated set of streaming services. Kodi can, through various add-on programs that create extra menu items, access a great many alternative streaming services that are available across the Internet. It can also show your own photos and the media files you may have on your computer and display them on your TV. It is even possible to run Kodi on a the Firestick media streamer sold by Amazon as a replacement for their own media playing program. Amazon is also a good place to buy these third-party media streamers. Just search for kodi on Amazon.
One of these generic media players loaded with Kodi is perfectly legal. However, some of the add-on programs that can be downloaded and added to Kodi have been known to allow access to media streams breach copyright laws in some countries. These streams are typically full of movies and TV shows. Getting Kodi add-on programs to work can be a bit tricky for the inexperienced. But sellers who ship such Kodi-equipped boxes fully loaded with potentially illegal add-on programs do so at risk of prosecution. There has just been a court case about this in the UK.
There a plenty of websites dedicated to reviews of Kodi add-on programs and comparisons between media streaming gadgets. As internet access gets faster and more reliable, it is becoming easier to watch TV through Internet-based media streaming services. It is becoming THE way to watch movies and TV shows, especially in resolution.
Large media companies have always sought to control the distribution of audio and video whatever technology was used: tapes, CDs, DVDs, Satellite and Cable subscriptions. Now video streaming over the Internet is the new battleground.
Incidentally, Kodi also runs quite happily on a PC or Mac.