Putting your sim card into a different phone is in no way illegal.
You do not need to inform your network provider that you have done this either.
Secondly, unlocking a handset to allow it to take any sim card is also in no way illegal.
Not many phones are locked in the way they all used to be so often you can buy a new handset and simply swap sim cards.
I believe that as PAYG bundles go these days, only orange still lock the handsets to their own network.
For example, I have had a Vodafone sim for ten years, and the last 2 phones I bought were Virgin PAYG handsets, as they were the cheapest bundle. I used the free credit that came with the virgin sims, then chucked them away and put in my Vodafone sim. (Your number does not change)