Question: I have a `header.php` file which contains the code from Google Analytics.

This file is included in each page of the website.

Will the Google search rankings change if I modify the pages (for example change the position of some `divs` and tables and apply a new design)?

The text will mostly remain the same.

Is it possible to lose the already existing rankings?

Answer: 
Google Analytics "Rankings" or SERPs - Search Engine Results Placements? For SERPS, yes HTML/markup can influence it, depending on the depth of the change and the initial value of your markup. 

Like @bybe said, 

> 
> Google does however reward for good design such as accessibility and
>  responsive design
> 
> 
> 

This means that you get improved search results for being mobile-friendly, as well as following standard accessibility guidelines (W3C is a good place to start). 

Page load time is another accessibility/usability factor to consider. If you significantly reduce the amount of time your page takes to load (size of image files, weight of CSS and JS files), you also see a boost in search engine results.

As well, if you change the location of links or comments away from the body to the footer, header, or sidebar, that can influence the way Google sees the weighting of those individual items towards your page's topical authority. (example: linking towards all of your friends' blogs in the "body" would be seen as SPAMmy and potentially bad, whereas putting them in the sidebar would be less SPAMmy, while increasing the strength of your page's individual topics).

SERPS can also be influenced by schema markup (Event Dates, Local Business Addresses, Products, Ratings, etc.) - <https://schema.org/> 

SERPS are tailored to the searcher - location, device, query, logged-in status, search-history, YouTube & Google+ relationships, etc. So, the more you can improve the accessibility, descriptiveness, and social connectivity of your website, the better your SERPS will be.
I suppose you're talking about the rankings in Google search results?

In that case, any change to a site architecture can be risky, but Google has gotten really good at distinguishing the site structure (menus, sidebars, site-wide/repetitive divs) from actual website content.

In other words, if you make some changes to the site layout without disturbing the text, urls and the site structure as google currently sees it, the risks should be minimal.

But like I said, noone here can guarantee that site changes will not mess up your rankings.