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: 
Thraka is right that BASIC served the role of operating system on many 8-bit micros. *Some* OS was needed, that was beyond doubt. But at the time dedicated operating systems were either very limited (say, Atari DOS), overly complex, big and expensive for the tiny computers (Unix), or - for the middle ground, that was "just right" - in their infancy (CP/M).

BASIC, on the other hand, was touted THE beginner's programming language. 

At the time - 8-bit micros were primarily aimed at the kids and teens market. They were "home computers", where the dad could write and print letters, mom could design crosstitch images, but 90% of the time kids would be playing games. But if the computer was to be more than a glorified gaming console with hardly-used extra functions, it needed a marketing point that would set it apart from the consoles: **"It Teaches Your Kids Programming"** was the critical sales point. And so it needed a kid-friendly programming language.

BASIC had only one serious competitor for that position at the time: [Logo](https://en.wikipedia.org/wiki/Logo_%28programming_language%29), and while Logo was generally considered a much better learning tool\* but it hardly yielded towards "general use" - you could do some quite fancy stuff easily (drawing a [Koch Snowflake](https://en.wikipedia.org/wiki/Koch_snowflake) was less than a screen long program; not a packed screen too) but didn't yield well towards "common use", and was considerably slower. Other languages than the two either employed concepts too advanced for kids, or were too complex to implement on 8-bit micros (leaving enough memory for actual software too!).

...also - Microsoft Basic was an important language for "professional environment". Learning its simpler variants was considered (usually by clueless parents) an important building block towards building a career of using it professionally. Nobody ever wrote serious business software in Logo. Therefore the marketing appeal of Basic - despite its factual shortcomings - overshadowed Logo as THE language for learning.

On top of that, implementing OS procedures as BASIC commands was simple, natural and took little effort, little memory and allowed to integrate or script them as BASIC programs easily. Logo didn't yield itself to that purpose nearly as well.

And so, BASIC being simultaneously a comfortable OS environment, a scripting tool, a teaching tool, and - above all - an important marketing point - became the language of choice.

\* (e.g. providing recursion, which was between very difficult and impossible in Basic, lacking local variables, parametric function calls and rarely implementing easy to access arrays which could serve as a crutch for these). Also, the Turtle Graphics, which was excellent for teaching the concept of "giving commands", and building a library of procedures, but made utilizing the gfx as "pixel canvas" difficult.
As it says in Wikipedia [BASIC](https://en.wikipedia.org/wiki/BASIC):

> 
> The introduction of the first microcomputers in the mid-1970s was the start of explosive growth for BASIC. It had the advantage that it was fairly well known to the young designers and computer hobbyists who took an interest in microcomputers.  
> 
>  ... BASIC was one of the few languages that was both high-level enough to be usable by those without training and small enough to fit into the microcomputers of the day, making it the de facto standard programming language on early microcomputers.
> 
> 
> 

In other words, it was easy to learn even for those with no programming experience, and the interpreter memory footprint was small, which was important due to the cost of memory.  

(I don't exactly recall, but back in the 80s an 8k bit RAM chip in C64 cost several dollars.)

The use of an interpreter was also important from an ease of use point. While other existing languages were similar and not so difficult to learn (for example FORTRAN), they had to be compiled. 

This means that instead of getting instant results (or errors), you had to write the code, compile it (hopefully no errors otherwise you had to change the code again and compile again), and then run it. If any errors, back to square one you go.