@Sh4d0wsPlyr accurately sums up the RAW and gives a possible in-game explanation that would make sense within a setting.
A counterpoint to trying to justify the RAW is to remember that the focus of roleplaying game is not to play the rules but to experience a campaign. Any RPG Campaign has a setting whether it is an entire world like Forgotten Realms or a dungeon like Castle Blackmoor, or Tegel Manor.
The setting of a campaign has it own logic. It can be very different like M.A.R. Barker's Tekumel or a reflection of a fantasy medieval Europe like Gygax's Greyhawk. The setting logic often includes the way magic works, which in your case is focused on how spells get into spellbooks.
In past editions of D&D the acquisition of spells was treated naturally. Within the campaign, your character had to find another book with the spell in it and copy it. Or had to spend considerable time in doing magical research in creating the spell from scratch. The only mechanics governing this was the time and cost involved.
So for the referee of the campaign you are involved in, he obviously views that spells should be acquired from other sources and probably would agree that you could do research for a new spell.
Is your referee right in ruling as he did? The answer is not that simple. While the point of roleplaying games is to play a campaign in a setting with it own logic. The point of the rules is to be consistent in how the actions of the characters are adjudicated, along with defining the capabilities of creatures, characters, and objects in the campaign.
The problem with what your referee wants to do is that the ruling will change how the setting works according to the RAW in the MIDDLE of the campaign. If he laid out the change at the beginning of the campaign, you may have disagreed with it but at least you could have factored that in to any decision you made as your character. So while your referee has the right to make the ruling that spells for spellbook has to be acquired in-game, based on the information you provided it would not be a fair ruling.
I personally try to avoid doing this in the middle of the campaign. If I find something I don't like about the rules I am using, I will make the fix for the next campaign I run and just live with it for the current campaign.
But on the other hand I have been running my Majestic Wilderlands setting for a series of campaigns stretching back 30 years. I know how magic works in my campaign, along with other things. When I use a new set of rules, like D&D 5e in 2014, to run a new Majestic Wilderlands, I can make a sheet of house rules to communicate to my players how I adapted it to my setting.
A referee with a new campaign or limited experience may not have thought of the implications of everything before the start of the campaign. In this case it is best to just talk it out and come up with a consensus that works for everybody. Whether to make the change right then and there, to make it for the next campaign, or perhaps it is just not a good idea for any campaign after further reflection that RAW is the way to go. (I had a few of those myself).
Finally (specific to your issue) is to remember that in D&D 5e you can cast a lower level prepared spell through the slot of a higher level spell. Some spells, like magic missile, will receive a benefit this way, other won't. So if your campaign decides that spells have to be acquired in-game, you will still benefit from having higher level slots.