Question: There are a lot of retro-computers with BASIC as an integral part of the operating system. The IBM 5100 was one of the first computers with a separate memory space for BASIC, followed by the Commodore PET, Apple II and TRS-80.

But why was BASIC built into their operating systems, using memory? From [this memory map](http://sta.c64.org/cbm64mem.html), the Commodore 64 had memory completely reserved for BASIC. There were computers, like the Altair 8800, that provided BASIC as software that could be loaded into memory when necessary, and these computers both worked and sold well.

So why was BASIC built into so many computers' operating systems?

Answer: 
In addition to the answers above, something to keep in mind is that there wasn't a ton of commercial software available at the time compared to today and computers were not yet things that everyone needed or even found useful for their jobs. It's not like today where you could buy a computer, load it with Office and other software, use it to do your job, maybe even run your business and turn it into a multimillion dollar operation, and never touch a line of code. 

Meanwhile when I went to college in 1995 I had fellow freshmen who could barely get their PC turned on but they knew how to program in Pascal because the American school system at the time taught programming because they didn't know what else to do with these computer things everyone is buying, but they knew that it was going to be a "thing" in the future. 

So one of the reasons a lot of these old toy computers came with BASIC built in was because, compared to today, they didn't do much else. And they also tended to not run the software from the previous generation or any other computers (if you think about it, Apple's never completely shaken this mindset - they have few qualms about breaking backwards compatibility for machines more than a few years old and they sell a computer that can't run the software from the competition's platforms). Notice how it wasn't until the DOS/Windows cycle started happening that backwards compatibility became a big thing and then sales of computer took off. There were other factors too, like price, but it inspired a lot of consumer confidence when you could be reasonably certain your stuff could come along for the ride.
Once upon a time, 16 kilobytes of DRAM was expensive. The original 8080 Altair came with up to 4 kbytes of memory on a single memory board.

The only programming languages (higher than ASM) that could fit in that small a memory were Tiny BASIC (Palo Alto Tiny BASIC, Altair BASIC (Gates and Allen) and Woz's Integer BASIC, et.al.) and Forth. The only alternatives were hand coding assembly language, or cross-compiling on a larger minicomputer. Basic was more well known and far more commercially viable than entering programs in binary via front panel switches. Later personal computers continued with what the market was familiar with (from the books and magazine articles at that time), and came with BASIC loaded into ROM. 

So the answer is:

BASIC (with a very simple OS for I/O) came in ROM on many early personal computers because mass-produced masked ROM was cheaper than RAM, on a per byte basis. 64k address space was considered huge at the time, so dedicating a portion of it to ROM was not considered wasteful. And BASIC in ROM allowed the computer to be usable on power-up, instead of after loading software via paper-tape, cassette tape, or some other media.