At the service they told me that the earliest version of android that can connect to internet and youtube is 5.1, is it so?
No, all versions of Android connected to the internet and YouTube, but the current versions of apps may not work in 4.0.4.
As a flip phone fan I wanna buy some sharp phone model that is based on android and all of them - that I know of - are with 5.1 version and below.
That's because no one bought flip phones with Android after that. (Having 100 customers world-wide for a product in a field that has millions of customers doesn't make economic sense. Even if a single manufacturer sold all 100 phones, it costs more than they make to just design the phone.)
Also I'm curious, if the 5.1 android is the earliest
It's not. I was on the internet, and could go to YouTube, on 2.2.3.
what will be in the near future, maybe the 5.1 version will stop working and android 6 will be the earliest android for internet, and youtube?
No, the apps will stop working on 5.1. Then they'll stop working on 6. Then they'll stop working on 7, etc. Apps use functions that exist in Android at the time they're released. So if an app is released in 2019, it may use a function that didn't exist in Android in 2016. Or even 2018. Developers don't spend a week developing and debugging a function that's available in Android, they just use it. If your version of Android doesn't have it, the app stops working. But ... if you get the app from Play, and nowhere else,
and the app is written correctly, so the minimum version as listed in the app is, say 6, Play won't even show you the app if you're running 5.1. If you install it from somewhere else, you're on your own. (My Samsung Precedent, running Android 2.2.3,
still gets on the internet, and still can get to YouTube. But it has a very old version of all the apps on it.)
And, what about upgrading, can every device that is 5.1 android stock be upgraded to a later version, or it isnt so for every device?
The manufacturer develops the interface software that sits between stock Android and the hardware, and even flagship phones (aside from Google phones) don't get more than 2 version updates. A phone on 5.1 couldn't be updated to 9 or 10, even if you knew how to write the interface software - it doesn't have the hardware to run an a/b system, which is what Android is now. (When you update, you update to "the other side", and the phone doesn't switch to that side unless the update was successful. So no more bricked phones because the battery died during an update. The phone will try an update again later and, if it's successful, then it switches. [Something I was asking for, for quite a few years - the technology was there at least as far back as 1989 - I know, I wrote the same sort of update system for another type of device.] But a phone running 5.1 can't do that, so if it came with 5.1 - which yours didn't - and was a flagship phone - which yours isn't - it would be limited to about 7.)
That's one reason people get new phones every few years. A great new app or hardware comes out, you want it desperately - but your phone can't do it.