If you omit the container you'll get a full-width layout.
Jumbotron example
Jumbotron is a good example of the container behavior. If you put a Jumbotron element in a container element it has rounded borders and a fixed width based on the responsive width.
If the Jumbotron is outside a container, it spans full-width without borders.
Class 'container' wraps the content within to center of view port.
Entire content with in body tag can be placed in results the page displayed of specified width in center of page.
Class 'row' is used when you need to place content in columns with in a row, you can have upto 12 columns in total in each row.
For the row class you can use row class when you want to design tabular layout for the page, but when you want to display data in table format you should use table class, but the table will not be responsive.
To create tabular layout which different from data tables use the row class like in this example:
I was wondering about the same and to understand that I went through the bootstrap.css of version 3. The answer lies in from line no. 1585 to 1605. I'll post those lines here for better understanding as below.
Whole of the code is self explanatory. However, to elaborate on this, container would take 750px if screen width is between 768px and 992px and so forth as the code shows. Now, for common screen resolution of more than 1200, container would take 1170px, but subtracting the padding of 30 px (15px+15px), the effective space left is 1140px, which is centered on the screen as the margin of left and right is set to auto.
Now, in case of class="row", there is below code:
.row {
margin-right: -15px;
margin-left: -15px;
}
So, if row is inside the container, it would effectively snatch the padding of 15px each side from the container and use the full space. But if the class row is inside the body tag, it would tend to move out of the visible area into both the left and right side of the browser due to negative margins.
The container provide the width constraints on responsive widths. When the responsive sizes change, it’s the container that changes. Rows and columns are all percentage based so they don’t need to change.
Note that there is a 15px margin on each side, canceled by rows.
Rows
Rows should always be in a container.
The row provides the columns a place to live, ideally having columns that add up to 12. It also acts as a wrapper since all the columns float left, additional rows don’t have overlaps when floats get weird.
Rows also have a 15px negative margin on each side. The div that makes up the row would normally be constrained inside of the containers padding, touching the edges of the pink area but not beyond. The 15px negative margins push the row out over top of the containers 15px padding, essentially negating it. Furthermore, rows ensure you that all of the divs inside of it appear on their own line, separated from the previous and the following rows.
Columns
The columns now have 15px padding. This padding means that the columns actually touch the edge of the row, which itself touches the edge of the container since the row has the negative margin, and the container has the positive padding. But, the padding on the column pushes anything inside the column in to where it needs to be, and also provides the 30px gutter between columns. Never use a column outside of a row, it won’t work.
For more information, I suggest you to read this article. It is really clear, and explain well how Bootstrap's grid system works.
For the benefit of future readers, the Bootstrap Grid (container/row/col) has evolved since this question was asked originally for Bootstrap 3. However, many concepts and "rules" still apply:
"Containers are the most basic layout element in Bootstrap and are required when using our default grid system."
"Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins to ensure the content in your columns is visually aligned down the left side. "
Therefore...
1 - Use a container or container-fluid to contain the entire page layout. You can put any content (text, images, headings) inside the container. Bootstrap 5 now provides additional responsive containers.
2 - If you want a multi-column layout use the Grid. The grid consists of at least 1 row with 1 or more columns (col*) inside it. You can put more than 12 columns in a single row. The only reason to use separate rows would be to create a new horizontal division.
Never...
Use a col-* without a row as it's immediate parent.